#ifndef SOLUTION_H
#define SOLUTION_H

/*	CLASS:		Solution
	AUTHOR:		Marcelo Y. B. Hossomi
	OBS:		Abstract class

	Contains solution data.
*/

#include "Problem.h"
#include "Instance.h"
#include "InvalidIndex.h"
#include "NotReady.h"

class Solution {
protected:
	int		size;		// Solution size
	int		cols, rows;	// Solution matrix size
	int		*value;		// Solution values

	bool	ready;		// 'true' if has been created

public:
	Solution();
	~Solution();

	// Create solution from problem instance.
	bool create( Problem *problem );

	// Create solution from instance.
	bool create( Instance *instance );

	// Get/set value in array.
	int& operator [] (int i) throw (InvalidIndex, NotReady);

	// Get value in matrix.
	int get( int i, int j ) throw (InvalidIndex, NotReady);

	// Set value in matrix.
	void set( int i, int j, int x ) throw (InvalidIndex, NotReady);

	// Check if solution is ready.
	bool isReady() { return ready; }
};

#endif